<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - FooTable</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="/static/favicon.ico"> <link href="/static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/static/css/plugins/footable/footable.core.css" rel="stylesheet">

    <link href="/static/css/animate.css" rel="stylesheet">
    <link href="/static/css/style.css?v=4.1.0" rel="stylesheet">
    <!-- Sweet Alert -->
    <link href="/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>用户信息</h5>
                        </div>
                        <div class="ibox-content">
                            {% for msg in get_flashed_messages()%}
                                <p class="login-box-msg">{{msg}}</p>
                            {% endfor %}
                            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="8">
                                <thead>
                                <tr>
                                    <th data-toggle="true">邮箱</th>
                                    <th>用户名</th>
                                    <th>身份</th>
                                    <th data-hide="all">性别</th>
                                    <th data-hide="all">生日</th>
                                    <th data-hide="all">注册时间</th>
                                    <th data-hide="all">最后登录时间</th>
                                    <th>升级</th>
                                    <th>删除</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for user in users %}
                                <tr>
                                    <td>{{user.email}}</td>
                                    <td>{{user.username}}</td>
                                    <td>
                                        {% if user.role_id==1 %}
                                            普通用户
                                        {% elif user.role_id==2 %}
                                            协管员
                                        {% else %}
                                            超级管理员
                                        {% endif %}
                                    </td>
                                    <td>
                                        {% if user.sex==0 %}
                                            男
                                        {% else %}
                                            女
                                        {% endif %}
                                    </td>
                                    <td>{{user.birthday}}</td>
                                    <td><span class="pie">{{user.create_time}}</span></td>
                                    <td>{{user.end_time}}</td>
                                    <td>
                                        {% if user.role_id==1 %}
                                             <a href="{{url_for('admin.upgrade',id=user.id)}}">升级为协管员</a>
                                        {% endif %}
                                        {% if user.role_id==2 %}
                                             <a href="{{url_for('admin.downgrade',id=user.id)}}">降级为普通用户</a>
                                        {% endif %}
                                    </td>
                                    <td>
                                        {% if user.role_id<=2 %}
                                        <a href="javascript:;" onclick="userDelete('{{user.id }}')"> 删除该用户</a>
                                        {% endif %}
                                    </td>
                                </tr>
                                {% endfor %}
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="5">
                                        <ul class="pagination pull-right"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    <!-- 全局js -->
    <script src="/static/js/jquery.min.js?v=2.1.4"></script>
    <script src="/static/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/static/js/plugins/footable/footable.all.min.js"></script>

    <!-- 自定义js -->
    <script src="/static/js/content.js?v=1.0.0"></script>
    <!-- Sweet alert -->
    <script src="/static/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script>
        $(document).ready(function() {

            $('.footable').footable();
            $('.footable2').footable();

        });
        function userDelete(user_id){
            swal({
                    title: "您确定要删除这个用户吗？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "删除",
                    closeOnConfirm: false
                }, function () {
                    window.location.href='delete/'+user_id
                });
        }
    </script>

    
    

</body>

</html>
